package cn.cxion.chat.app.constant;

import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import cn.cxion.chat.R;
import cn.cxion.chat.app.bean.AppointmentInfo;
import cn.cxion.chat.app.bean.CheckContractBean;
import cn.cxion.chat.app.bean.CurrentBean;
import cn.cxion.chat.app.bean.OptionBean;
import cn.cxion.chat.app.bean.SecBean;

public class Constant {
    public static Constant instance = null;

    //待处理状态
    public static int waitDispose =0;
    public static int onHand=1;
    public static int alreadyDispose=2;

    //流程
    public static int startDemand=1;
    public static int claim =2;
    public static int checkcontrack=3;
    public static int approve=4;

    public static int OPTIONLINE = 0;
    private static Map<Integer, CurrentBean> classBeanMap;
    private static Map<Integer, String> classKeyMap;
    private static Map<Integer, String> optionNameMap;
    private static Map<Integer, Integer> imageMap;
    public final static int TEST = 0;
    public final static int COUNTSAFE = 1;
    public final static int SELECTMODE = 2;
    public final static int CHANGEPWD1 = 3;
    public final static int CHANGEPWD2 = 4;
    public final static int MYCOLLECTION = 5;
    public final static int MYDATA = 6;
    public final static int CUSTOMERDATA = 7;


    public final static int HEADPORTRAIT = 8;
    public final static int NICKNAAME = 9;
    public final static int SEX = 10;
    public final static int PHONE = 11;
    public final static int EMAIL = 12;
    public final static int POST = 13;
    public final static int ADDRESS = 14;
    public final static int CHANGEPOST = 15;
    public final static int PASSWORD = 16;
    public final static int FILE = 17;
    public final static int IMAGE = 18;
    public final static int POSITION = 19;
    public final static int CHATRECODE = 20;
    public final static int INTERACTIVE = 21;
    public final static int VOICECALL = 22;
    public final static int VIDEOIMAGES = 23;
    public final static int EMERGENCYNEED = 24;
    public final static int CONTRACTCREATION = 26;
    public final static int CHECKCONTRACT = 27;
    public final static int LEGALADVICE = 28;
    public final static int RESERVATIONNUMBER = 29;
    public final static int LAWYERSLETTER = 30;
    public final static int LAWYERS = 31;
    public final static int BUSINESSNEGOTIATION = 32;
    public final static int LEGALOPINION = 33;
    public final static int COMPANYDATA = 34;
    public final static int PRIVATEPOLICY = 35;
    public final static int LEGALAGREEMENT = 36;
    public final static int APPOINTMENTLAWYER = 37;
    public final static int CHANGEPHONE = 38;

    public final static int APPOINTMENTCUSTOMER = 39;
    public final static int LEGALTRAINING = 40;
    public final static int LOVTIDENDE = 41;
    public final static int DEMANDDETAILS = 42;
    public final static int CLAIM = 43;
    public final static int CONTRACTDETAILS = 44;
    public final static int CLAIMDETAIL = 45;
    public final static int APPROVE = 46;
    public final static int CUSTOMERAPPROVE = 47;
    public final static int ADDSCHEDULE = 48;
    public final static int INVITEE = 49;






    public final static int CHANGEBYOLDPWDVIEW= 1001;
    public final static int CHANGEBYPHONEVIEW = 1002;
    public final static int CHECKCONTRACTVIEW = 1003;
    public final static int CONTRACTCREATIONVIEW = 1004;
    public final static int LEGALADVICEVIEW = 1005;
    public final static int APPOINTMENTLAWYERVIEW = 1006;

    public static List<CheckContractBean> contractBeanList;
    public static List<AppointmentInfo> scheduleBeanList;

    public static List<OptionBean> addScheduleTagList;
    public static List<OptionBean> addScheduleRepeatList;



    public static Constant getInstance() {
        if (instance == null) {
            synchronized (Constant.class) {
                instance = new Constant();
                init();
            }
        }
        return instance;
    }

    private static void init() {
        initClassMap();
    }

    //各个项目名
    private static void initClassMap() {
        classBeanMap = new HashMap<>();
        classKeyMap = new HashMap<>();
        optionNameMap = new HashMap<>();
        contractBeanList=new ArrayList<>();
        scheduleBeanList=new ArrayList<>();
        //注册页面名称
        classKeyMap.put(TEST, "测试页面");
        classKeyMap.put(COUNTSAFE, "账号与安全");
        classKeyMap.put(SELECTMODE, "选择方式");
        classKeyMap.put(CHANGEPWD1, "修改密码");
        classKeyMap.put(CHANGEPWD2, "修改密码");
        classKeyMap.put(MYCOLLECTION, "我的收藏");
        classKeyMap.put(MYDATA, "我的数据");
        classKeyMap.put(CUSTOMERDATA, "客户数据");
        classKeyMap.put(COMPANYDATA, "公司数据");
        classKeyMap.put(HEADPORTRAIT, "更改头像");
        classKeyMap.put(NICKNAAME, "更改昵称");
        classKeyMap.put(SEX, "更改性别");
        classKeyMap.put(PHONE, "手机号");
        classKeyMap.put(CHANGEPHONE, "更改手机号");
        classKeyMap.put(EMAIL, "更改邮箱");
        classKeyMap.put(POST, "更改职务");
        classKeyMap.put(ADDRESS, "更改地址");
        classKeyMap.put(CHANGEPOST, "更改邮箱");
        classKeyMap.put(FILE, "文件");
        classKeyMap.put(IMAGE, "图片与视频");
        classKeyMap.put(POSITION, "位置");
        classKeyMap.put(CHATRECODE, "聊天记录");
        classKeyMap.put(INTERACTIVE, "互动聊天");
        classKeyMap.put(VOICECALL, "语音通话");
        classKeyMap.put(VIDEOIMAGES, "视频照片");
        classKeyMap.put(EMERGENCYNEED, "紧急需求");
        classKeyMap.put(CONTRACTCREATION, "合同起草");
        classKeyMap.put(CHECKCONTRACT, "合同审改");
        classKeyMap.put(LEGALADVICE, "法律咨询");
        classKeyMap.put(RESERVATIONNUMBER, "预约次数");
        classKeyMap.put(LAWYERSLETTER, "律师函");
        classKeyMap.put(LAWYERS, "律师会面");
        classKeyMap.put(BUSINESSNEGOTIATION, "商务谈判");
        classKeyMap.put(LEGALOPINION, "法律意见书");
        classKeyMap.put(LEGALAGREEMENT, "《高领Legal法律顾问服务协议》");
        classKeyMap.put(PRIVATEPOLICY, "《隐私政策》");
        classKeyMap.put(APPOINTMENTLAWYER, "预约律师");
        classKeyMap.put(APPOINTMENTCUSTOMER, "预约客户");
        classKeyMap.put(LEGALTRAINING, "法律培训");
        classKeyMap.put(LOVTIDENDE, "法律月刊");
        classKeyMap.put(DEMANDDETAILS, "需求详情");
        classKeyMap.put(CONTRACTDETAILS, "审改详情");
        classKeyMap.put(CLAIM, "认领操作");
        classKeyMap.put(CLAIMDETAIL, "认领详情");
        classKeyMap.put(APPROVE, "内部审批");
        classKeyMap.put(CUSTOMERAPPROVE, "客户确认");
        classKeyMap.put(ADDSCHEDULE, "新建日程");
        classKeyMap.put(INVITEE, "受邀人");
        //当选项卡与标题不同时在这里查找覆盖
        initOptionMap();
        initImageMap();
        for (int key : classKeyMap.keySet()) {
            classBeanMap.putAll(getMap(key, null));
        }
        //注册页面内容
        classBeanMap.get(COUNTSAFE).setSecList(getSecList(PHONE, SELECTMODE));
        classBeanMap.get(SELECTMODE).setSecList(getSecList(CHANGEPWD1, CHANGEPWD2));
        classBeanMap.get(MYCOLLECTION).setSecList(getSecList(FILE, IMAGE, POSITION, CHATRECODE));
        classBeanMap.get(MYDATA).setSecList(getSecList(INTERACTIVE, VOICECALL, VIDEOIMAGES, EMERGENCYNEED,
                CONTRACTCREATION, CHECKCONTRACT, LEGALADVICE, RESERVATIONNUMBER, LAWYERSLETTER, LAWYERS, BUSINESSNEGOTIATION, LEGALOPINION));
        classBeanMap.get(COMPANYDATA).setSecList(getSecList(INTERACTIVE, VOICECALL, VIDEOIMAGES, EMERGENCYNEED,
                CONTRACTCREATION, CHECKCONTRACT, LEGALADVICE, RESERVATIONNUMBER, LAWYERSLETTER, LAWYERS, BUSINESSNEGOTIATION, LEGALOPINION));
        classBeanMap.get(CHANGEPWD1).setSecList(getSecList(CHANGEBYOLDPWDVIEW));
        classBeanMap.get(CHANGEPWD2).setSecList(getSecList(CHANGEBYPHONEVIEW));
        classBeanMap.get(CHECKCONTRACT).setSecList(getSecList(CHECKCONTRACTVIEW));
        classBeanMap.get(CONTRACTCREATION).setSecList(getSecList(CONTRACTCREATIONVIEW));
        classBeanMap.get(LEGALADVICE).setSecList(getSecList(LEGALADVICEVIEW));
        classBeanMap.get(NICKNAAME).setSecList(getSecList(NICKNAAME));
        classBeanMap.get(SEX).setSecList(getSecList(SEX));
        classBeanMap.get(PHONE).setSecList(getSecList(CHANGEPHONE));
        classBeanMap.get(EMAIL).setSecList(getSecList(EMAIL));
        classBeanMap.get(POST).setSecList(getSecList(POST));
        classBeanMap.get(ADDRESS).setSecList(getSecList(ADDRESS));
        classBeanMap.get(DEMANDDETAILS).setSecList(getSecList(DEMANDDETAILS));
        classBeanMap.get(CLAIM).setSecList(getSecList(CLAIM));
        classBeanMap.get(CONTRACTDETAILS).setSecList(getSecList(CONTRACTDETAILS));
        classBeanMap.get(CLAIMDETAIL).setSecList(getSecList(CLAIMDETAIL));
        classBeanMap.get(APPROVE).setSecList(getSecList(APPROVE));
        classBeanMap.get(CUSTOMERAPPROVE).setSecList(getSecList(CUSTOMERAPPROVE));
        classBeanMap.get(ADDSCHEDULE).setSecList(getSecList(ADDSCHEDULE));
        setClassBeanMap(classBeanMap);
        setClassKeyMap(classKeyMap);
        initList();
    }

    private static void initList(){
        addScheduleTagList=new ArrayList<>();
        addScheduleTagList.add(new OptionBean(0,"永不"));
        addScheduleTagList.add(new OptionBean(1,"一次"));
        addScheduleTagList.add(new OptionBean(2,"一直"));
        addScheduleRepeatList=new ArrayList<>();
        addScheduleRepeatList.add(new OptionBean(0,"一般"));
        addScheduleRepeatList.add(new OptionBean(1,"重要不紧急"));
        addScheduleRepeatList.add(new OptionBean(2,"紧急不重要"));
        addScheduleRepeatList.add(new OptionBean(3,"重要紧急"));
    }

    public static List<OptionBean> getAddScheduleTagList() {
        return addScheduleTagList;
    }

    public static List<OptionBean> getAddScheduleRepeatList() {
        return addScheduleRepeatList;
    }

    /**
     * 选项卡与标题不同时在这里修改
     *
     * @author qiancheng
     * creat by 2019/9/17 0:06
     **/
    private static void initOptionMap() {
        optionNameMap.putAll(classKeyMap);
        replace(SELECTMODE, "密码");
        replace(CHANGEPWD1, "通过旧密码方式修改");
        replace(CHANGEPWD2, "通过手机号验证修改");

    }

    public static List<CheckContractBean> getContractBeanList() {
        return contractBeanList;
    }

    public static List<AppointmentInfo> getScheduleBeanList() {
        return scheduleBeanList;
    }

    /**
     * 在这里添加选项卡图片
     *
     * @author qiancheng
     * creat by 2019/9/17 0:11
     **/
    private static void initImageMap() {
        imageMap = new HashMap<>();
        imageMap.put(FILE, R.mipmap.file);
        imageMap.put(IMAGE, R.mipmap.imgs);
        imageMap.put(POSITION, R.mipmap.position);
        imageMap.put(CHATRECODE, R.mipmap.recode);
        imageMap.put(INTERACTIVE, R.mipmap.interactive);
        imageMap.put(VOICECALL, R.mipmap.voicecall);
        imageMap.put(VIDEOIMAGES, R.mipmap.videoimages);
        imageMap.put(EMERGENCYNEED, R.mipmap.emergencyneed);
        imageMap.put(CONTRACTCREATION, R.mipmap.contractcreation);
        imageMap.put(CHECKCONTRACT, R.mipmap.checkcontract);
        imageMap.put(LEGALADVICE, R.mipmap.legaladvice);
        imageMap.put(RESERVATIONNUMBER, R.mipmap.reservationnumber);
        imageMap.put(LAWYERSLETTER, R.mipmap.lawyersletter);
        imageMap.put(LAWYERS, R.mipmap.lawyers);
        imageMap.put(BUSINESSNEGOTIATION, R.mipmap.businessnegotiation);
        imageMap.put(LEGALOPINION, R.mipmap.legalopinion);


    }

    private static void replace(int key, String name) {
        optionNameMap.remove(key);
        optionNameMap.put(key, name);
    }


    public static Map<Integer, CurrentBean> getClassBeanMap() {
        return classBeanMap;
    }

    public static void setClassBeanMap(Map<Integer, CurrentBean> classBeanMap) {
        Constant.classBeanMap = classBeanMap;
    }

    public static Map<Integer, String> getClassKeyMap() {
        return classKeyMap;
    }

    public static void setClassKeyMap(Map<Integer, String> classKeyMap) {
        Constant.classKeyMap = classKeyMap;
    }


    private static Map<Integer, CurrentBean> getMap(int key,SecBean[] secBeans) {
        Map<Integer, CurrentBean> map = new HashMap<>();
        CurrentBean bean = new CurrentBean();
        bean.setClassId(key);
        bean.setClassName(classKeyMap.get(key));
        List<SecBean> list = new ArrayList<>();
        for (int i = 0; i < (secBeans == null ? 0 : secBeans.length); i++) {
            list.add(secBeans[i]);
        }
        bean.setSecList(list);
        map.put(key, bean);
        return map;
    }

    private static List<SecBean> getSecList(int... keys) {
        List<SecBean> list = new ArrayList<>();
        for (int i = 0; i < (keys == null ? 0 : keys.length); i++) {
            SecBean bean = new SecBean(keys[i]);
            bean.setClassName(classKeyMap.get(keys[i]));
            bean.setOptionTitle(optionNameMap.get(keys[i]));
            bean.setLeftImage(imageMap.get(keys[i]) == null ? 0 : imageMap.get(keys[i]));
            list.add(bean);
        }
        return list;
    }

}
